﻿<?php 
    $id=empty($_GET['id'])?'':$_GET['id'];

    //新建数组用于重组的分类数组
 if(!empty($_POST)){

// print_r($_POST);die;
      $_rows=edxit($GLOBALS['c'],$id,$_POST);
      
      $data=selectone()
    if ($_rows>0) {
        echo '<script>alert("编辑成功"); location.href="index.php?c=cate&a=list&admin=1";</script>';die;
        # code...
    }else{
        echo'<script>alert("编辑失败");history.go(-1);</script>';die;
    }

        
}



    $sql="select * from `cate` where `id`=$id"; //查询当前操作的id对象

  	$result=mysqli_query($GLOBALS['link'],$sql);

  	$data=mysqli_fetch_assoc($result);

  	$cate=adxitCate($data);  //当前操作的pid



  	
  	function adxitCate($data,$cate=array()){		

	$sql="select * from `cate` where `pid`=".$data['pid'];//查找同级id

  	$result=mysqli_query($GLOBALS['link'],$sql);

  	while ( $arr=mysqli_fetch_assoc($result)) {
  		 $cate[$data['id']][]=$arr;

}
if ($data['pid']!=0) {

    $sql="select * from `cate` where `id`=".$data['pid']; //查询父级

  	$result=mysqli_query($GLOBALS['link'],$sql);

  	$data=mysqli_fetch_assoc($result);

  	$cate=adxitCate($data,$cate);

  	
	# code...
}
	return $cate=array_reverse($cate,true);

  	}
  	
    
  
 include VIEW_PATH.$admin.'layout.html';
 //先做添加以作基础//

//编写插入数据的sql语句
